import numpy as np
import cv2 as cv
import os
import sys
sys.path.append(os.getcwd())
from config.env import Env
env = Env()

img = cv.imread(env.getImgPath() + "roi.jpg")

'''
这种方式不推荐
'''
px = img[100, 100]
print(px)

blue = img[100, 100, 2]
img[100, 100] = [255, 255, 0]
print(blue)

'''
使用这种方式
'''
px2 = img.item(100, 100, 1)
print(px2)
img.itemset((100, 100, 2), 255)
print(img.shape)
print(img.size)
print(img.dtype)
ball = img[230:280, 270:325]

ballGary = cv.cvtColor(ball, cv.COLOR_BGR2GRAY)
ret, mask = cv.threshold(ballGary, 145, 170, cv.THRESH_BINARY)

img[60:110, 165:220] = ball

b, g, r = cv.split(img)
img2 = cv.merge((r, b , g))

img2[: , :, 2] = 0

border = cv.copyMakeBorder(img2, 10, 10, 10, 10 ,cv.BORDER_WRAP)
print(b)
print(g)
print(r)

cv.imshow("img", mask)
cv.waitKey(0)
cv.destroyAllWindows()